import select
import socket
import time

sk = socket.socket()
sk.bind(('127.0.0.1', 8000))
sk.setblocking(False)
sk.listen()

read_lst = [sk]
while 1:
    #print('已经完了')
    r_lst, w_lst, x_lst = select.select(read_lst, [], [])
    print(r_lst)
    for i in r_lst:
        if i is sk:
            conn, addr = i.accept()
            read_lst.append(conn)
        else:
            #print('等待着')
            #time.sleep(5)
            ret = i.recv(1024)
            if ret == b'':
                i.close()
                read_lst.remove(i)
                continue
            #print(ret)
            i.send(b'goodbye')
